package org.budo.datasource.routing.connection;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.budo.datasource.routing.BudoRoutingDataSource;

/**
 * @author lmw
 */
public class BudoRoutingConnection extends AbstractBudoRoutingConnection {
    public BudoRoutingConnection() {}

    public BudoRoutingConnection(Connection defaultConnection, BudoRoutingDataSource routingDataSource) {
        this.setDefaultConnection(defaultConnection);
        this.setRoutingDataSource(routingDataSource);
    }

    @Override
    public void close() throws SQLException {
        this.getDefaultConnection().close();
    }

    @Override
    public DatabaseMetaData getMetaData() throws SQLException {
        return this.getDefaultConnection().getMetaData();
    }

    @Override
    public String getCatalog() throws SQLException {
        return this.getDefaultConnection().getCatalog();
    }

    @Override
    public boolean getAutoCommit() throws SQLException {
        return this.getDefaultConnection().getAutoCommit();
    }

    @Override
    public void setAutoCommit(boolean autoCommit) throws SQLException {
        this.getDefaultConnection().setAutoCommit(autoCommit);
    }

    @Override
    public void rollback() throws SQLException {
        this.getDefaultConnection().rollback();
    }

    @Override
    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
        // this.getRoutingDataSource()
        // return this.getRoutingConnection(sql).prepareStatement(sql, autoGeneratedKeys);
        return null;
    }

    @Override
    public PreparedStatement prepareStatement(String sql) throws SQLException {
        //        return this.getRoutingConnection(sql).prepareStatement(sql);
        return null;
    }
}